package cn.wowjoy.pda.android_pharmacy.model.xml;

import com.google.gson.Gson;

import org.simpleframework.xml.Root;
import org.simpleframework.xml.Text;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by 84429 on 2017/4/18.
 */

@Root(name = "string", strict = false)
public class XmlData {
    @Text
    public String Text;

    public <T> T getData(Class<T> t) {
        try {
            return new Gson().fromJson(Text, t);
        } catch (Exception e) {
            return null;
        }
    }

    public <T> List<T> getListData(final Type type) {
        try {
            return new Gson().fromJson(Text, type);
        } catch (Exception e) {
            return new ArrayList<>();
        }
    }
}
